﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Themes/Shared/Seller.Master" Inherits="System.Web.Mvc.ViewPage<GoodsForm>" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
修改商品信息
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="HeadContent" runat="server">
    <script src="<%=Url.Content("~/js/swfupload.js")%>" type="text/javascript"></script>
    <script src="<%=Url.Content("~/js/uploadfile.js")%>" type="text/javascript"></script>
    <script src="<%=Url.Content("~/js/skus.js")%>" type="text/javascript"></script>
    <script src="<%=Url.Content("~/ckeditor/ckeditor.js")%>" type="text/javascript"></script>
    <script type="text/javascript">
        (function ($) {
            $(function () {
                //主图片上传
                window['GOODS_SWF_UPLOAD'] = InitSwfUploadFile({
                    upload_url: '<%=Url.Action("UploadImgs","Ajax") %>',
                    flash_url: '<%=Url.Content("~/js/swfupload.swf")%>',
                    button_image_url: '<%=Url.Content("~/Style/Images/member/SmallSpyGlassWithTransperancy_17x18.png")%>'
                });
                
                //描述内容图片上传
                InitSwfUploadFile({
                    upload_url: '<%=Url.Action("UploadImgs","Ajax") %>',
                    flash_url: '<%=Url.Content("~/js/swfupload.swf")%>',
                    file_upload_limit: 10,
                    file_queue_limit: 10,
                    button_text: '<span class="button">上传产品图片</span>',
                    button_image_url: '<%=Url.Content("~/Style/Images/member/SmallSpyGlassWithTransperancy_17x18.png")%>',
                    button_placeholder_id: "goodsImg",
                    custom_settings: {
                        upload_target: "goods_img_progress",
                        if_multirow: 1
                    },
                    file_queued_handler: function(file) {
                        try {
                            var html = '<div class="fileItem" id="' + file.id + '"><span class="fileName">' + file.name + '</span><span class="progressStatus">文件就绪</span>';
                            html += '<div class="progressBar"></div></div>';
                            $("#goods_img_progress").append(html);
                        } catch (e) {
                            this.debug(e);
                        }
                    },
                    upload_success_handler: function(file, serverData) {
                        try {
                            var fileData = eval('(' + serverData + ')');
                            if (fileData.IsUpload) {
                                $("#" + file.id + " .progressStatus").html("上传成功");
                                //添加图片到页面
                                $('#goods_img_list_content').append('<li><img src="' + fileData.Path + '" width="55" height="55" /><input name="Images" type="hidden" value="' + fileData.Path + '" /></li>');
                            } else {
                                $("#" + file.id + " .progressStatus").html("文件上传失败");
                            }

                            $("#" + file.id).fadeOut(1000, function () { $(this).remove();});
                            initEditImages();
                        } catch (ex) {
                            this.debug(ex);
                        }
                    },
                    file_dialog_complete_handler: function (numFilesSelected, numFilesQueued) {
                        try {
                            if (numFilesQueued > 0) {
                                this.startUpload();
                            }
                        } catch (ex) {
                            this.debug(ex);
                        }
                    }
                });

                //分类处理
                $("#CategoryID").change(function () {
                    $("#tb_protype").html("正在获取数据……");
                    $.get('<%=Url.Action("GetCategory", "Ajax")%>', { "cateId": $(this).val(),"gid":<%=Model.GoodsID%> }, function (data) {
                        $("#tb_protype").html(data);
                        //组合suk数据
                        InitSUKsData();
                    });
                }).change();

                //上传文件
                $("#open_uploader").click(function () {
                    var isShow = $(this).find("b").attr('class') != "hide";
                    if (!isShow) {
                        $("#uploader").show();
                        $(this).find("b").attr('class', 'show');
                    } else {
                        $("#uploader").hide();
                        $(this).find("b").attr('class', 'hide');
                    }
                });
                
                //===
                initEditImages();
            });
        })(jQuery);
    </script>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="MainContent" runat="server">
<ul class="tab">
    <li class="normal"><%=Html.ActionLink("商品列表", "ProductList")%></li>
    <li class="active">修改产品</li>
</ul>
<div class="wrap" id="addGoods">
<%using (Html.BeginForm()){ %>
    <div>修改商品<span style="font-size:13px; color: #FF0000; font-weight:normal;">（发布有问题请在线咨询：<a href="tencent://message/?uin=2241899011" target="_blank" style="color:#FF0000;"><img src="http://wpa.qq.com/pa?p=1:615050000:10" alt="路口客服" border="0"></a>）</span></div>
    <h4>商品基本信息</h4>
    <% 
        List<GoodsImage> majorImages = (List<GoodsImage>)ViewData["majorImages"];
        GoodsImage fImg = majorImages.FirstOrDefault();
    %>
    <div class="goodsItems">
        <div class="pic_list">
            <div class="big_pic">
                <img id="big_goods_image" src="<%=(fImg!=null)?fImg.ImgURL:Url.Content("~/Style/Images/default_goods_image.jpg")%>" />
            </div>
            <div class="small_pic">
                <ul id="goods_images">
                    <% foreach (var img in majorImages){%>
                    <li>
                        <img src="<%=img.ImgURL%>" width="55" height="55" />
                        <input name="MajorImages" type="hidden" value="<%=img.ImgURL%>" />
                    </li>
                    <%}%>
                </ul>
            </div>

            <div class="clear"></div>

            <div class="upload_btn">
                <div class="upload" id="open_uploader"><b class="hide">上传商品图片</b></div>
                <div class="upload_con" id="uploader" style="display:none;">
                    <ul>
                        <li class="btn1">
                           <span id="spanButtonPlaceholder"></span>
                        </li>
                        <li id="open_remote" class="btn2">远程地址</li>
                    </ul>

                    <div id="goods_upload_progress"></div>

                    <div class="upload_txt">支持JPEG和静态的GIF格式图片，不支持GIF动画图片，上传图片大小不能超过5M.浏览文件时可以按住ctrl或shift键多选</div>
                </div>
            </div>
        
        </div>
        <div class="products">
            <p>
                <%=Html.LabelFor(m=>m.CategoryID) %>
                <%=Html.DropDownListFor(c => c.CategoryID, (List<SelectListItem>)ViewData["CategoryOptions"])%>
                <%=Html.ValidationMessageFor(m => m.CategoryID)%>
            </p>
            <p>
                <%=Html.LabelFor(m=>m.Name) %>
                <%=Html.TextBoxFor(m=>m.Name)%>
                <%=Html.ValidationMessageFor(m => m.Name)%>
            </p>

            <p>
                <%=Html.LabelFor(m=>m.Brand) %>
                <%=Html.TextBoxFor(m => m.Brand)%>
                <%=Html.ValidationMessageFor(m => m.Brand)%>
            </p>

            <p>
                <%=Html.LabelFor(m=>m.Tags) %>
                <%=Html.TextBoxFor(m => m.Tags)%>
                <%=Html.ValidationMessageFor(m => m.Tags)%>
            </p>

            <p>
                <%=Html.LabelFor(m=>m.Price) %>
                <%=Html.TextBoxFor(m => m.Price)%>
                <%=Html.ValidationMessageFor(m => m.Price)%>
            </p>

            <p>
                <%=Html.LabelFor(m=>m.Stock) %>
                <%=Html.TextBoxFor(m => m.Stock)%>
                <%=Html.ValidationMessageFor(m => m.Stock)%>
            </p>

            <p>
                <%=Html.LabelFor(m=>m.SUK) %>
                <%=Html.TextBoxFor(m => m.SUK)%>
                <%=Html.ValidationMessageFor(m => m.SUK)%>
            </p>

            <p>
                <%=Html.LabelFor(m=>m.IsShow) %>
                <%=Html.CheckBoxFor(m=>m.IsShow)%>
                <%=Html.ValidationMessageFor(m => m.IsShow)%>
            </p>

            <p>
                <%=Html.LabelFor(m=>m.Recommended) %>
                <%=Html.CheckBoxFor(m => m.Recommended)%>
                <%=Html.ValidationMessageFor(m => m.Recommended)%>
            </p>
            
            <p>
                <%=Html.LabelFor(m=>m.DownLevel) %>
                
                <%=Html.ValidationMessageFor(m => m.DownLevel)%>
            </p>
        </div>
        <div class="clear"></div>
    </div>

    <h4>淘宝商品信息</h4>
    <div class="goodsItems" id="tb_protype"></div>

    <h4>商品描述</h4>
    <div class="goodsItems" style="background:#F6F6F6;border:1px solid #E8E8E8;">
        <div>
            <%=Html.FckTextBox("Description", Model.Description, "734", "450")%>
            <%=Html.ValidationMessageFor(m => m.Description)%>
        </div>
        <div class="goods_img_list">
            <div style="padding: 15px;">
                <span id="goodsImg"></span>
                <div id="goods_img_progress"></div>
            </div>
            <div class="clear"></div>
            <div id="goods_img_list">
                <ul id="goods_img_list_content">
                    <% foreach (var img in (List<GoodsImage>)ViewData["images"]){%>
                    <li>
                        <img src="<%=img.ImgURL%>" width="55" height="55" />
                        <input name="Images" type="hidden" value="<%=img.ImgURL%>" />
                        <div class="tips">插入图片</div>
                    </li>
                    <%}%>
                </ul>
                <div class="clear"></div>
            </div>
        </div>
    </div>

    <div style="padding-left: 150px;">
        <input class="btn" type="submit" value="提交" />
    </div>
<%}%>
</div>
</asp:Content>
